package com.smart.controller;

import com.smart.common.WebResponse;
import com.smart.model.vo.DictItemVO;
import com.smart.service.DictItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Example;
import io.swagger.annotations.ExampleProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhanghong
 */
@RestController
@RequestMapping("/dictItem")
@Api(tags = {"A通用模块#字典项模块"})
public class DictItemController {

    @Autowired
    private DictItemService dictItemService;

    //@ApiOperation(value = "根据主键查询", httpMethod = "POST")
    //@ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    //@PostMapping("/get/{id}")
    //public WebResponse<DictItemVO> getByKey(HttpServletRequest request, @PathVariable("id") long id) {
    //    return WebResponse.build(dictItemService.getByKey(id));
    //}
    //
    //@ApiOperation("分页查询")
    //@PostMapping("/pageQuery")
    //public WebResponse<PageInfo<DictItemVO>> pageQuery(@RequestBody DictItemRequest request) {
    //    return WebResponse.build(dictItemService.pageQuery(request));
    //}
    //
    //@ApiOperation("列表查询")
    //@PostMapping("/listQuery")
    //public WebResponse<List<DictItemVO>> listQuery(@RequestBody DictItemRequest request) {
    //    return WebResponse.build(dictItemService.listQuery(request));
    //}
    //
    //@ApiOperation("新增")
    //@PostMapping("/add")
    //public WebResponse<Boolean> add(@Valid @RequestBody DictItemRequest request) {
    //    return WebResponse.build(dictItemService.add(request));
    //}
    //
    //@ApiOperation("修改")
    //@PostMapping("/update")
    //public WebResponse<Boolean> updateByKey(@Valid @RequestBody DictItemRequest request) {
    //    return WebResponse.build(dictItemService.updateByKey(request));
    //}

    /**
     * USER_HESUAN -人员核酸检测方式;
     * ENV_HESUAN -环境核酸检测方式;
     * BUILD_TYPE -施工状态;
     * PROJECT_TYPE -工程类型;
     * USER_JOB -人员职务;
     * UNIT -单位性质;
     *
     * @param dictCode
     * @return
     */
    @ApiOperation(value = "根据字典code查询字典项", httpMethod = "POST")
    @ApiImplicitParam(name = "dictCode", value = "字典编码", required = true)
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/queryDictItemByDictCode/{dictCode}")
    public WebResponse<List<DictItemVO>> queryDictItemByDictCode(@PathVariable("dictCode") String dictCode) {
        return WebResponse.build(dictItemService.queryDictItemByDictCode(dictCode));
    }
}
